{if (($fans['status']==2 || ($theme['endtime']+432000) < TIMESTAMP) && $system['s']['isshare']==1) }
<script>
    {else}
    {php echo $config['iswxshare']==0?$register_jssdk:"<script src='https://res.wx.qq.com/open/js/jweixin-1.3.2.js'></script>";}

<script>

    var GLat;
    var GLng;
    var orderid  = 0;
    var orderno = '';
    var isflag = false;
    var shareData = {
        title: '{$sharetitle}',
        desc: '{$sharedesc}',
        imgUrl: '{$shareimgurl}',
        link: '{$shareurl}'
    };
    var wxapp_share_path = "{$wxapp_share_path}";
    wx.ready(function () {

        // 添加应用往webview 发送分享的信息
        const ua = window.navigator.userAgent.toLowerCase()
        if (ua.indexOf('micromessenger') > -1) {
            // 判断是否是微信环境
            wx.miniProgram.getEnv(function (res) {
                if (res.miniprogram) { // 小程序环境
                    const message = {
                        title: shareData.title,
                        imgUrl: shareData.imgUrl,
                        path:wxapp_share_path
                    }
                    wx.miniProgram.postMessage({
                        data: {
                            message
                        }
                    })
                } else {
                    // 非小程序环境下逻辑
                    // console.log('不在小程序中')
                }
            })
        }

        {if $open_position==1}
        wx.getLocation({
            type: 'gcj02', //wgs84 或 gcj02
            success: function (res) {
                GLat = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                GLng = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                // $(".btns a").eq(0).attr('href',$(".btns a").eq(0).attr('href')+"uhubnunhbu");
                let user_location = "&user_location="+GLat+","+GLng;
                let new_user_location = GLat+","+GLng;


                //一个价格
                for (let i=0;i<$(".btns a").length;i++){
                    let temp_href_val = $(".btns a").eq(i).attr('href');
                    if (temp_href_val.indexOf('javascript')<0){
                        // $(".btns a").eq(i).attr('href',$(".btns a").eq(i).attr('href')+"&location="+user_location);
                        $(".btns a").eq(i).attr('href',$(".btns a").eq(i).attr('href')+"&user_location="+new_user_location);
                    }
                }
                //两个价格
                for (let i=0;i<$(".twoBtn a").length;i++){
                    let temp_href_val = $(".twoBtn a").eq(i).attr('href');
                    if (temp_href_val.indexOf('javascript')<0){
                        $(".twoBtn a").eq(i).attr('href',$(".twoBtn a").eq(i).attr('href')+"&user_location="+new_user_location);
                    }
                }
                var postUrl = '/{php echo createMobileUrl("wx",array("themeid"=>$themeid,"from"=>"mobile","r"=>"education.index.GetShangJiaByLg"));}';
                $.ajax({
                    type:'POST',
                    dataType:'json',
                    data: {user_location:new_user_location,page:1},
                    url:postUrl,
                    success:function (res){
                        var data = res.data;
                        if (data){
                            $("#serviceList_ul").html(data.serviceList);
                            $("#lessconChose").html(data.lessconChoseItems);
                            $(".reload_location").html(data.edu_success_location_tips);
                        }
                    }
                });
            },
            cancel:function(res){
                alert('您拒绝授权定位信息，将无法获得位置推荐');
                $(".reload_location_div").css("display",'flex');
            },
            fail: function (res) {
                // alert(JSON.stringify(res));
            }
        });
        {/if}




        {if $canshare == 0}
        wx.hideOptionMenu();
        {else}
        wx.showOptionMenu();
        {/if}


            wx.onMenuShareAppMessage({
                title: shareData.title,
                desc: shareData.desc,
                link: shareData.link,
                imgUrl: shareData.imgUrl,
                trigger: function (res) {
                },
                success: function (res) {

                    setTimeout(function(){
                        dosharepyq(0);
                    }, 500);
                },
                cancel: function (res) {
                },
                fail: function (res) {
                }
            });

            wx.onMenuShareTimeline({
                title: shareData.title,
                link: shareData.link,
                imgUrl: shareData.imgUrl,
                success: function () {
                    setTimeout(function(){
                        dosharepyq(1);
                        {if $config['iscomm']==1 && $config['comm41'] > 0}
                        dosharehb();
                        {/if}
                            {if $config['iscomm']==1 && $system['fenxiao07'] > 0}
                            doyaoyiyaohb();
                            {/if}
                            }, 500);
                },
                cancel: function () {
                }
            });

        });

    wx.error(function (res) {
    });

    {/if}

        $(function(){
            $("#topay").click(function() {

                var status = $('#status').val();
                if(status == "0"){
                    layer.msg('活动尚未开始哦');
                    return false;
                }
                if(status == "2"){
                    layer.msg('活动已经结束啦');
                    return false;
                }
                {if (!empty($myworker) && $myworker['level']<=3 && empty($config['isworkerpay']))}

                layer.msg('员工不可以报名,如需测试请用非员工微信');
                return false;
                {/if}

                    {if $isyixuan == true}

                    layer.msg('客户活动进行中,不可测试');
                    return false;
                    {/if}

                        var address = $("#address").val();
                        {if $config['shopstype'] == 0 }
                        // var option = $('#shops option:selected').val();
                        var option = $("#shops").val();
                        {else}
                        var option = $("#shops").val();
                        {/if}
                            var code = $('#code option:selected').val();
                            var datetime = $("#datetime").val();
                            var addinfo = $("#addinfo").val();
                            var xieyi = $("input[name='xieyi']:checkbox").attr('checked');
                            {if !empty($config['shops'])}
                            if(option.length <=0){
                                layer.msg('请选择{$config['shops']}');
                                return false;
                            }
                            {/if}

                                var joinidv = 0;
                                var username = $('#nametext').val();
                                var mobile = $("#mobiletext").val();
                                var formtwo = $("#formtwo").val();
                                if(username.length == 0){

                                    layer.msg('请输入{$config['nametext']}');
                                    return false;
                                }
                                if(mobile.length != 11){

                                    layer.msg('请输入格式正确的{$config['mobiletext']}');
                                    return false;
                                }
                                {if !empty($config['formtwo'])}
                                    if(formtwo.length <=0){
                                        layer.msg('请输入{$config['formtwo']}');
                                        return false;
                                    }
                                {/if}

                                {if !empty($config['address'])}
                                if(address.length <=0){
                                    layer.msg('请输入{$config['address']}');
                                    return false;
                                }
                                {/if}
                                    {if !empty($config['datetime'])}
                                    if(datetime.length <=0){
                                        layer.msg('请输入{$config['datetime']}');
                                        return false;
                                    }
                                    {/if}
                                        {if !empty($config['addinfo'])}
                                        if(addinfo.length <=0){
                                            layer.msg('请输入{$config['addinfo']}');
                                            return false;
                                        }
                                        {/if}

                                            // closeBox();
                                            if(isflag){
                                                isflag = true;
                                                return false;
                                            }
                                            joinidv = "{php echo $joinid;}";
                                            recordid = "{php echo $recordid;}";
                                            console.log(joinidv);
                                            tips("正在支付...");
                                            $.ajax({
                                                type:'POST',
                                                dataType : "json",
                                                data:{joinid:joinidv,recordid:recordid,username:username,formtwo:formtwo,mobile:mobile,address:address,option:option,code:code,datetime:datetime,addinfo:addinfo,course_address:confirm_course_address,
                                                    gift_ids:gift_ids},
                                                url:'/{php echo createMobileUrl("yxpay",array("op"=>"ready","themeid"=>$themeid,"recordid"=>$recordid,"workerid"=>$workerid,"fromuid"=>$fromuid,"fopenid"=>$fopenid));}',
                                                success:function(data){
                                                    var json = data.message;
                                                    if (json && json.orderid){
                                                        let ua = window.navigator.userAgent.toLowerCase()
                                                        if (ua.indexOf('micromessenger') > -1) {
                                                            // 判断是否是微信环境
                                                            wx.miniProgram.getEnv(function (res) {
                                                                if (res.miniprogram) { // 小程序环境
                                                                    wx.miniProgram.navigateTo({
                                                                        url: `/pages/yxpay/yxpay?orderid=`+json.orderid
                                                                    })
                                                                    return;
                                                                } else {
                                                                    // 非小程序环境下逻辑
                                                                    // console.log('不在小程序中')
                                                                }
                                                            })
                                                        }
                                                    }

                                                    if(json.errcode == 0){
                                                        if(json.payway == 0){
                                                            window.location.href = json.url;
                                                        }else{
                                                            //tips(json.tid);
                                                            util.pay({
                                                                orderFee : json.fee,
                                                                payMethod : 'wechat',
                                                                orderTitle : json.title,
                                                                orderTid : json.tid,
                                                                module : '{$_P['m']}',
                                                                success : function(result) {
                                                                    {if empty($config['payedurl'])}
                                                                    tips2('支付成功',window.location.href);
                                                                    {else}
                                                                    tips2('支付成功','{$config["payedurl"]}');
                                                                    {/if}
                                                                    },
                                                                    fail : function(result) {
                                                                        alert('fail : ' + result.message);
                                                                    },
                                                                    complete : function(result) {
                                                                        location.reload();
                                                                    }
                                                                });
                                                        }
                                                    }else if(json.errcode == 110){
                                                        tips2(json.msg,json.url);
                                                    }else if(json.errcode == 111){
                                                        tips2(json.msg,window.location.href+'&username='+json.username+'&mobile='+json.mobile);
                                                    }else{
                                                        tips2(json.msg,'/{php echo createMobileUrl("index",array("themeid"=>$themeid));}');
                                                    }
                                                }
                                            });
                                        });

            $(".reload_location").on("click",function () {
                console.log('用户二次点击授权位置')
                window.location.href = "{$jump_map_url}";
            });
        })


        function checkorder(){
            if(orderno== ""){
                alert('定单号为空');return false;
            }
            $.ajax({
                type:'POST',
                dataType : "json",
                data:{orderid:orderid},
                url:'/{php echo createMobileUrl("yxpay",array("themeid"=>$themeid,"op"=>"check"));}',
                success:function(data){
                    var json = data.message;
                    if(json.errcode == 0){
                        tips2(json.msg,json.url);
                    }else{
                        checkorder();
                    }
                }
            });
        }
        function dosharepyq(type){
            $.ajax({
                type: 'POST',
                dataType : "json",
                url:'/{php echo createMobileUrl("sharepyq",array("themeid"=>$themeid,"workerid"=>$workerid,"fromuid"=>$fromuid,"fopenid"=>$fopenid));}',
                data: {type:type},
                success: function(data) {
                    data = data.message;
                    if(data.errcode == 0){
                        {if $config['isicon']>0 && $config['iconnum2'] == 0}

                        document.getElementById('mcover').style.display='';
                        document.getElementById('mcover1').style.display='';
                        $("#dark" + data.sharecount).attr('src',data.lightsum);
                        ds.dialog({
                            title : '&#25805;&#20316;&#25552;&#31034;',
                            content : '您的有效&#20998;&#x4eab;次数为'+data.lightsum+'次',
                            yesText : '&#30830;&#23450;',
                            timeout :3.5,
                        });
                        return false;
                        {/if}
                        }else{
                            if (data.msg){tips(data.msg);}
                        }
                    },
                    error: function() {
                    }
                });
        }
        {if $config['iscomm']==1 && $config['comm41'] > 0}
        function dosharehb(){
            $.ajax({
                type: 'POST',
                dataType : "json",
                url:'/{php echo createMobileUrl("sharehb",array("themeid"=>$themeid,"op"=>"comm"));}',
                data: {GLat:GLat,GLng:GLng},
                success: function(data) {
                    data = data.message;
                    if(data.errcode == 3){
                        ds.dialog({
                            title : '&#25805;&#20316;&#25552;&#31034;',
                            content : '&#24685;&#21916;&#24744;&#33719;&#24471;&#32418;&#21253;'+data.fee+'&#20803;',
                            yesText : '&#30830;&#23450;',
                            timeout :3.5,
                        });
                        return false;
                    }else{
                        if(data.errcode == 2){
                            ds.dialog({
                                title : '&#25805;&#20316;&#25552;&#31034;',
                                content : '&#24685;&#21916;&#24744;&#33719;&#24471;&#32418;&#21253;'+data.fee+'元,自动到账'+data.fee2+'&#20803;',
                                yesText : '&#30830;&#23450;',
                                timeout :4.0,
                            });
                            return false;
                        }else{
                            if(data.errcode == 5){
                                ds.dialog({
                                    title : '&#25805;&#20316;&#25552;&#31034;',
                                    content : data.msg,
                                    yesText : '&#30830;&#23450;',
                                    timeout :3.5,
                                });
                                return false;
                            }else{
                                tips(data.msg);
                            }}}
                },
                error: function() {
                }
            });
        }
        {/if}
            {if $config['iscomm']==1 }
            function doyaoyiyaohb(){

                wid = {php echo empty($workerid)?0:$workerid;};
                $.ajax({
                    type: 'POST',
                    dataType : "json",
                    url:'/{php echo createMobileUrl("yaoyiyao",array("themeid"=>$themeid,"op"=>"pyq"));}',
                    data: {GLat:GLat,GLng:GLng,wid:wid},
                    success: function(data) {
                        data = data.message;
                        if(data.errcode == 3){
                            ds.dialog({
                                title : '&#25805;&#20316;&#25552;&#31034;',
                                content : '&#24685;&#21916;&#24744;&#33719;&#24471;&#32418;&#21253;'+data.fee+'&#20803;',
                                yesText : '&#30830;&#23450;',
                                timeout :3.5,
                            });
                            return false;
                        }else{
                            if(data.errcode == 2){
                                ds.dialog({
                                    title : '&#25805;&#20316;&#25552;&#31034;',
                                    content : '恭喜您,红包到账'+data.fee2+'&#20803;',
                                    yesText : '&#30830;&#23450;',
                                    timeout :4.0,
                                });
                                return false;
                            }else{
                                if(data.errcode == 5){
                                    ds.dialog({
                                        title : '&#25805;&#20316;&#25552;&#31034;',
                                        content : data.msg,
                                        yesText : '&#30830;&#23450;',
                                        timeout :5.0,
                                    });
                                    return false;
                                }else{
                                    tips(data.msg);
                                }}}
                    },
                    error: function() {
                    }
                });
            }
            {/if}
</script>